---@class AlreadySelectTargetCondition:AbstractCondition
local AlreadySelectTargetCondition = ClientFight.CreateClass("AlreadySelectTargetCondition",ClientFight.AbstractCondition)
---@return EStatus
function AlreadySelectTargetCondition:update()
   SkillRoleMgr.savePathFile( "[" .. self.fight.frame .. "][目标判断]" .. self.fighter:print() .. "进行目标选择判断");
    --无法选择技能
    if(self.fighter.prepareSkill == nil) then
        return EStatus.SUCCESS
    end
    --强制重新选择目标（魅惑）
    if(self.fighter.resetPrepareTarget) then
       SkillRoleMgr.savePathFile( "[" .. self.fight.frame .. "][目标判断]" .. self.fighter:print() .. "强制重新选择目标");
        self.fighter.resetPrepareTarget = false
        self.fighter.prepareTarget = nil
        return EStatus.FAILURE
    end
    if self.fighter.prepareTarget ~= nil then
        local skillBean = self.fighter.prepareSkill.skillBean
        --如果目标变为不可选择，重新选择目标
        if skillBean.f_Target == SkillTargetTypeEnum.FRIEND and FighterStateEnum.is(self.fighter.prepareTarget,FighterStateEnum.CAN_NOT_SELECT_BY_FRIENDLY) then
            self.fighter.prepareTarget = nil
           SkillRoleMgr.savePathFile( "[" .. self.fight.frame .. "][目标判断]" .. self.fighter:print() .. "目标变为不可选择，重新选择目标");
            return EStatus.FAILURE
        elseif skillBean.f_Target == SkillTargetTypeEnum.TARGET and FighterStateEnum.is(self.fighter.prepareTarget,FighterStateEnum.CAN_NOT_SELECT_BY_ENEMY) then
            self.fighter.prepareTarget = nil
           SkillRoleMgr.savePathFile( "[" .. self.fight.frame .. "][目标判断]" .. self.fighter:print() .. "目标变为不可选择，重新选择目标");
            return EStatus.FAILURE;
        elseif skillBean.f_Target == SkillTargetTypeEnum.FRIEND_AND_ONESELF then
            if self.fighter.prepareTarget ~= self.fighter then
                if FighterStateEnum.is(self.fighter.prepareTarget,FighterStateEnum.CAN_NOT_SELECT_BY_FRIENDLY) then
                    self.fighter.prepareTarget = nil
                   SkillRoleMgr.savePathFile( "[" .. self.fight.frame .. "][目标判断]" .. self.fighter:print() .. "目标变为不可选择，重新选择目标");
                    return EStatus.FAILURE;
                end
            end
        end
    end
    --已经拥有目标
    if self.fighter.prepareTarget ~= nil and not self.fighter.prepareTarget:isDie() then
       SkillRoleMgr.savePathFile( "[" .. self.fight.frame .. "][目标判断]" .. self.fighter:print() .. "已经选择过目标");
        return EStatus.SUCCESS;
    end
    self.fighter.prepareTarget = nil
   SkillRoleMgr.savePathFile( "[" .. self.fight.frame .. "][目标判断]" .. self.fighter:print() .. "可以进行目标选择");

    return EStatus.FAILURE;
end